package com.example.hang.msgqueue;

import android.os.Handler;
import android.os.Message;
import android.widget.Toast;

import java.util.ArrayList;
import java.util.List;

/**
 * 消息处理类
 */
public class MsgHandler extends Handler {
    /**
     * 处理消息
     * @param msg 消息
     */
    @Override
    public void handleMessage(Message msg){
        if(msg.what == 0x123){
            int upper = msg.getData().getInt(Utility.UPPER_NUM);
            List<Integer> nums = new ArrayList<>();
            //
            outer:
            for(int i = 2; i <= upper; i++){
                for(int j = 2; j <= Math.sqrt(i);j++){
                    if(i != 2 && i %j == 0){
                        continue outer;
                    }
                }
                nums.add(i);
            }
            //Toast.makeText(HandlerUiMsgActivity.this,nums.toString(),Toast.LENGTH_LONG).show();
        }
    }
}
